<?php
class Admin_Form_AddOrder extends Apps_Form {
    public function init() {
        $dMapper = new M_Tool_DataMapper();
//         $tbTour = new M_DbTable_Tour();
        $listCruise = $dMapper->mapKeyValue(new M_DbTable_Cruise(), 'id', 'name');
//         $listTour = $dMapper->mapKeyValue($tbTour->getList()->query()->fetchAll(), 'id', 'title');
// 		foreach ($listTour as $key => $value) {
// 			if($listCruise[$key]) continue;
// 			array_push($listCruise, $listTour[$key]);
// 		}

        // ORDER
        $referenceType = new Zend_Form_Element_Select(
        					      'reference_type',
                                  array(
                                      'label'         	=>  'Thuộc danh mục',
        							  'required'		=> true,
                                      'multiOptions'  	=>  array(
                                      						''										=> '',
                                      						M_DbTable_Order::REFERENCE_TYPE_TOUR 	=> 'Tour',
                                      						M_DbTable_Order::REFERENCE_TYPE_CRUISE 	=> 'Cruise',
                                      					),
                                      'attribs' => array(
                                          'class' => 'chainselect',
                                          'data-chainselect-source' => '/?ajax=list-reference-order',
                                          'data-chainselect-target' => '[data-chainselect-selector=\'list\']'
                                       )
                                  )
                );

        $reference = new Zend_Form_Element_Select(
        						'reference_id',
                                array(
                                	'label'   => 'Liên quan đến',
                                    'attribs' => array(
                                        'data-chainselect-selector' => 'list'
                                    )
                                )
                            );
        $reference->setRegisterInArrayValidator(false);
        $orderStatus = new Zend_Form_Element_Select(
        		'order_status_id',
        		array(
        				'label'         =>  'Kiểu mua hàng',
        				'required'		=> true,
        				'multiOptions'  =>  $dMapper->mapKeyValue(
        						new M_DbTable_OrderStatus(),
        						'id',
        						'title')
        		)
        );
        $paymentType = new Zend_Form_Element_Select(
        		'payment_type_id',
        		array(
        				'label'         =>  'Kiểu thanh toán',
        				'required'		=> true,
        				'multiOptions'  =>  $dMapper->mapKeyValue(
        						new M_DbTable_PaymentType(),
        						'id',
        						'title')
        		)
        );
        $description = new Zend_Form_Element_Textarea(
        		'description',
        		array(
        				'label'   => 'Description',
        				'filters' => array('StringTrim')
        		)
        );

// Form
		$this->setLegend('Thêm thông tin đặt hàng');
		$this->addElements(array(
					$referenceType,
					$reference,
					$orderStatus,
					$paymentType,
					$description
				));
        $this->addActionGroup();
        $this->makeup();
    }
}